<?php

namespace App\Admin\Actions\Grid;

use App\Admin\Forms\CheckComment as CheckCommentForm;
use Dcat\Admin\Widgets\Modal;
use Dcat\Admin\Grid\RowAction;

class CheckComment extends RowAction
{
    protected $title = '审核';

    protected $model;

    public function __construct(string $model = null)
    {
        $this->model = $model;
    }

    public function render()
    {
        $nickname = $this->row->nickname ?: $this->row->member->nickname;
        $content = $this->row->content;

        // 实例化表单类并传递自定义参数
        $form = CheckCommentForm::make()->payload(['id' => $this->getKey(), 'nickname' => $nickname, 'content' => $content, 'model' => $this->model]);

        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            ->button($this->title);
    }
}
